package com.medical.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.medical.framework.aspectj.lang.annotation.Log;
import com.medical.framework.aspectj.lang.enums.BusinessType;
import com.medical.project.system.domain.DiseaseCard;
import com.medical.project.system.service.IDiseaseCardService;
import com.medical.framework.web.controller.BaseController;
import com.medical.framework.web.domain.AjaxResult;
import com.medical.common.utils.poi.ExcelUtil;
import com.medical.framework.web.page.TableDataInfo;

/**
 * 慢性病证管理Controller
 * 
 * @author tale
 * @date 2020-06-16
 */
@RestController
@RequestMapping("/system/card")
public class DiseaseCardController extends BaseController
{
    @Autowired
    private IDiseaseCardService diseaseCardService;

    /**
     * 查询慢性病证管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:card:list')")
    @GetMapping("/list")
    public TableDataInfo list(DiseaseCard diseaseCard)
    {
        startPage();
        List<DiseaseCard> list = diseaseCardService.selectDiseaseCardList(diseaseCard);
        return getDataTable(list);
    }

    /**
     * 导出慢性病证管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:card:export')")
    @Log(title = "慢性病证管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DiseaseCard diseaseCard)
    {
        List<DiseaseCard> list = diseaseCardService.selectDiseaseCardList(diseaseCard);
        ExcelUtil<DiseaseCard> util = new ExcelUtil<DiseaseCard>(DiseaseCard.class);
        return util.exportExcel(list, "card");
    }

    /**
     * 获取慢性病证管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:card:query')")
    @GetMapping(value = "/{illCardNo}")
    public AjaxResult getInfo(@PathVariable("illCardNo") String illCardNo)
    {
        return AjaxResult.success(diseaseCardService.selectDiseaseCardById(illCardNo));
    }

    /**
     * 新增慢性病证管理
     */
    @PreAuthorize("@ss.hasPermi('system:card:add')")
    @Log(title = "慢性病证管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DiseaseCard diseaseCard)
    {
        return toAjax(diseaseCardService.insertDiseaseCard(diseaseCard));
    }

    /**
     * 修改慢性病证管理
     */
    @PreAuthorize("@ss.hasPermi('system:card:edit')")
    @Log(title = "慢性病证管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DiseaseCard diseaseCard)
    {
        return toAjax(diseaseCardService.updateDiseaseCard(diseaseCard));
    }

    /**
     * 删除慢性病证管理
     */
    @PreAuthorize("@ss.hasPermi('system:card:remove')")
    @Log(title = "慢性病证管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{illCardNos}")
    public AjaxResult remove(@PathVariable String[] illCardNos)
    {
        return toAjax(diseaseCardService.deleteDiseaseCardByIds(illCardNos));
    }
}
